import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Gao zhao xu
 * Date: 2023-09-16
 * Time: 8:33
 */
public class test {
    public static List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> list = new ArrayList<>();
        list.add(1);
        ret.add(list);
        for (int i = 1; i < numRows; i++){
            List<Integer> curRow = new ArrayList<>();
            curRow.add(1);
            for (int j = 0;j <= i - 2; j++){
                int a = ret.get(i - 1).get(j) + ret.get(i - 1).get(j + 1);
                curRow.add(a);
            }
            curRow.add(1);
            ret.add(curRow);
        }
        return ret;
    }
    public static void main(String[] args) {
        List<List<Integer>> ret = generate(5);
        System.out.println(ret);
    }
    public static void main4(String[] args) {
        Random random = new Random();
        int a = random.nextInt(1,10);

    }
        public static void func(String str1, String str2){
            ArrayList<Character> arrayList = new ArrayList<>();
            for (int i = 0; i < str1.length();i++){
                char ch = str1.charAt(i);
                if(!str2.contains(ch + "")){
                    arrayList.add(ch);
                }
            }
            for (Character x: arrayList){
                System.out.print(x);
            }
        }
        public static void main3(String[] args) {
            func("welcome to bit", "come");
        }
    public static void main2(String[] args) {
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add("abc");
        arrayList.add("def");
        System.out.println("============================");
        System.out.println(arrayList);//直接打印
        System.out.println("============================");
        for (int i = 0; i < arrayList.size(); i++) {//fori循环打印
            System.out.println(arrayList.get(i));
        }
        System.out.println("============================");
        for (String x:arrayList) {//foreach循环打印
            System.out.println(x);
        }
        System.out.println("============================");
        Iterator<String> it = arrayList.listIterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("============================");
    }
    public static void main1(String[] args) {
        ArrayList<String> arrayList = new ArrayList<>();
        System.out.println("============================");
        System.out.println(arrayList.add("abc"));//添加一个元素返回值为true
        System.out.println(arrayList);
        System.out.println("============================");
        ArrayList<String> arrayList1 = new ArrayList<>();
        arrayList1.add("def");
        arrayList1.add("hello");
        arrayList1.add("def");
        arrayList.addAll(arrayList1);//添加arrayList1中的所有元素
        System.out.println(arrayList);
        System.out.println("============================");
        arrayList.add(1,"abcd");//对应位置插入数据
        System.out.println(arrayList);
        System.out.println("============================");
        String a = arrayList.remove(1);//删除对应位置元素，且可以得到删除的元素
        System.out.println(arrayList);
        System.out.println(a);
        System.out.println("============================");
        System.out.println(arrayList.remove("abc"));//删除对应元素，返回为true
        System.out.println(arrayList);
        System.out.println("============================");
        String b = arrayList.get(0);//获取0下标的元素
        arrayList.set(1, "abc");//设置1下标元素为：abc
        System.out.println(b);
        System.out.println(arrayList);
        System.out.println("============================");
        arrayList.clear();//清空列表
        System.out.println(arrayList);
        System.out.println("============================");
        System.out.println(arrayList.contains("abc"));//判断元素是否在内
        System.out.println("============================");
        System.out.println(arrayList1.indexOf("def"));//返回第一个元素所在下标
        System.out.println("============================");
        System.out.println(arrayList1.lastIndexOf("def"));//返回最后一个元素所在下标
        System.out.println("============================");
        List<String> list = arrayList1.subList(0, 2);//截取arrayList1的前两个元素到list
        System.out.println(list);
        list.set(0, "abc");//截取的list元素被改变
        System.out.println();
        System.out.println(list);
        System.out.println("============================");
        System.out.println(arrayList1);//被截取的arrayList1元素对应改变
        System.out.println("============================");
    }
}
